package com.ctrip.demo.leetcode;

public class LeetCode504 {

    public static void main(String[] args) {
        System.out.println(new LeetCode504().convertToBase7(100));
    }


    public String convertToBase7(int num) {

        StringBuilder builder = new StringBuilder();

        if (num == 0) {
            return "0";
        }
        boolean flag = num <  0;
        num = Math.abs(num);
        while (num != 0) {
            builder.append(num % 7);
            num /= 7;
        }

        if (flag) {
            builder.append("-");
        }

        return builder.reverse().toString();
    }



}
